<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <!-- <button>登录</button> -->
  <script>
    // document.querySelector('button').onclick=() => {}

    // websocket实例化
    const ws = new WebSocket('ws://121.40.165.18:8800')


    // 监听连接成功
    ws.onopen = function () {
      console.log('连接成功')
    }

    // 监听消息   最重要
    ws.onmessage = function (event) {
      console.log('收到消息', event.data)
    }

    // 监听关闭
    ws.onclose = function () {
      console.log('连接关闭')
    }








  </script>
</body>
</html>